REASSIGN OWNED
REASSIGN OWNED — change the ownership of database objects owned by a database role
Synopsis
REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_USER | SESSION_USER }
Description
REASSIGN OWNED instructs the system to change the ownership of any database objects owned by old_role to new_role.
Parameters
old_role
The name of a role. The ownership of all objects owned by this role in the current database and all shared objects (databases, tablespaces) will be reassigned to new_role.
new_role
The name of the role that will become the new owner of the affected objects.
Notes
REASSIGN OWNED is often used to prepare for removing one or more roles. Since REASSIGN OWNED does not affect objects in other databases, this command typically needs to be executed in every database that contains objects owned by the roles being dropped.
REASSIGN OWNED requires membership in both the source role and the target role.
The DROP OWNED command can simply drop all database objects owned by one or more roles.
The REASSIGN OWNED command does not affect any privileges granted to old_roles on objects they do not own. Similarly, it does not affect default privileges created by ALTER DEFAULT PRIVILEGES. DROP OWNED can reclaim those privileges.